<template>
    <div class="container">
        <div class="top-header">
            <i class="icon-wrap" @click="goback()">
                <img src="../../commom/image/fanhui.png" />
            </i>
            <p class="title">订单详情</p>
        </div>
        <div class="receiving-information">
            <div class="header">
                <div class="left">收货信息:</div>
            </div>
            <div class="address">
                <i class="icon-wrap">
                    <img src="../../commom/image/daohangdizhi.png" />
                </i>
                <span class="text">
                     {{ order.community + order.point + order.point_address + order.room_num }}
                </span>
            </div>
            <div class="user">
                <i class="icon-wrap">
                    <img src="../../commom/image/renyuan.png" />
                </i>
                <span class="name">{{ order.delivery_name }}</span>
                <span class="phone">{{ order.delivery_tel }}</span>
            </div>
        </div>
        <div class="goods-information">
            <div class="header">商品信息:</div>
            <div class="order-foods">
                <div class="food" v-for="(food,index) in order.menus" :key="index">
                    <img class="img" :src="'http://47.104.186.142:8000/'+food.pic_url">
                    <div class="content">
                        <h3 class="title">{{food.name}}</h3>
                        <div class="describe">{{food.remark}}</div>
                        <div class="price-number">
                            <div class="price">
                                ￥{{food.price}}
                            </div>
                            <div class="number">
                                X{{food.amount}}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="order-information">
            <div class="header">
                <div class="left">订单信息:</div>
            </div>
            <div class="main">
                <div class="info-group">
                    <span class="left">订&nbsp;单&nbsp;号&nbsp;：</span>
                    <div class="right">{{order.order_num}}</div>
                </div>
                <div class="info-group" v-show="order.time_end?true:false">
                    <span class="left">付款时间：</span>
                    <span class="right">{{order.time_end}}</span>
                </div>
                <div class="info-group">
                    <span class="left">订单状态：</span>
                    <span class="right">{{order.status}}</span>
                </div>
                <div class="info-group">
                    <span class="left">实付金额：</span>
                    <span class="right">￥{{order.total_fee/100}}</span>
                </div>
                <div class="info-group">
                    <span class="left">优惠金额</span>
                    <span class="right">￥0.00</span>
                </div>
            </div>
        </div>
        <div class="operate-init">
            <div class="hint">
                <div class="title">温馨提示：</div>
                 <div class="content">下单成功24小时后系统自动确认收货，有疑问请致电客服热线：<br/><a href="tel:0311-66501030">0311-66501030</a>（技术支持）<br/><a href="tel:0311-69022061">0311-69022061</a>（订餐服务）</div>
            </div>
        </div>
    </div>
</template>

<script type="text/ecamscript-6">
import numFilter from "@/commom/js/numFilter";
export default {
  data() {
    return {
      order: [],
      userAddress: [],
    };
  },
  computed: {
    totlePrice() {
      let totlePrice = 0;
      this.order.menus.forEach(item => {
        totlePrice += item.amount * item.price;
      });
      return totlePrice;
    }
  },
  filters: {
    numFilter
  },
  created() {

    if(sessionStorage.getItem("setUserName") == null){
         this.$router.push({
           path: "/login"
        });
    }

    let _this = this;
    this.$axios({
      method: "get",
      url: "http://47.104.186.142:80/order/queryOrder",
      params: {
         order_num: localStorage.getItem("setOrderNum") // 参数是order_num
      }
    }).then(res => {
      _this.order = res.data.data[0];
      //console.log(_this.order)
    });
    
  },
  methods:{
      goback() {
          this.$router.push({
           path: `/orders`
        });
      }
  }
};
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
@import '~commom/stylus/mixin';

.container {
    overflow: hidden;
    background-color: #f0f0f0;
    min-height: 100vh;
    .top-header{
        height: 42px;
        background-color: #6b7e8d;
        position:relative;
        .icon-wrap {
             position:absolute;
             left:12px;
             top: 10px;
        }
        .title{
            text-align: center;
            line-height: 40px;
            color: #fff;
        }
    }

    .receiving-information {
        padding: 0 15px;
        background-color: #fffbf5;
        overflow: hidden;
        margin: 10px 0;

        .header {
            display: flex;
            align-items: center;
            height: 49px;
            border-bottom: 1px solid #eee;
            justify-content: space-between;

            .left {
                font-size: 15px;
                color: #333333;
                font-weight: bold;
            }
        }

        .address {
            display: flex;
            margin: 20px 0 22.5px;

            .icon-wrap {
                margin-right: 15px;
            }

            .text {
                line-height: 20px;
                color: #333333;
                font-size: 14px;
            }
        }

        .user {
            display: flex;
            margin: 22.5px 0 20px;

            .icon-wrap {
                margin-right: 15px;
            }

            span {
                line-height: 20px;
                color: #333333;
                font-size: 14px;

                &.phone {
                    margin-left: 20px;
                }
            }
        }
    }

    .goods-information {
        padding: 0 15px;
        background-color: #ffffff;
        overflow: hidden;
        margin: 10px 0;

        .header {
            height: 49px;
            line-height: 49px;
            color: #333333;
            font-size: 15px;
            font-weight: bold;
        }

        .order-foods {
            .food {
                padding: 10px 0;
                border-top: 1px solid #eeeeee;
                display: flex;

                .img {
                    flex: 0 0 105px;
                    width: 105px;
                    height: 70px;
                    margin-right: 15px;
                }

                .content {
                    flex: 1;

                    .title {
                        color: #333;
                        font-size: 15px;
                        font-weight: bold;
                    }

                    .describe {
                        color: #666;
                        font-size: 13px;
                        line-height: 16px;
                        height: 32px;
                        line-hidden(2);
                        margin: 5px 0;
                    }

                    .price-number {
                        display: flex;
                        justify-content: space-between;
                        align-items: center;

                        .price {
                            color: #f20c00;
                            font-size: 12px;
                        }

                        .number {
                            font-size: 13px;
                            color: #333333;
                        }
                    }
                }
            }
        }
    }

    .order-information {
        padding: 0 15px;
        background-color: #ffffff;
        overflow: hidden;
        margin: 10px 0;

        .header {
            padding: 20px 0 10px;
            border-bottom: 1px solid #eee;

            .left {
                font-size: 15px;
                color: #333333;
                font-weight: bold;
            }
        }

        .main {
            color: #666666;
            font-size: 13px;
            margin: 10px 0;

            .info-group {
                display: flex;
                height: 30px;
                align-items: center;

                .left {
                    display: block;
                    flex: 0 0 65px;
                }

                .right {
                    display: block;
                    flex: 1;
                    color: #333333;
                }
            }
        }
    }

    .operate-init {
        margin-top: 10px;

        .hint {
            padding: 15px;
            background-color: #fffbf5;
            display: flex;
            align-items: flex-start;
            font-size: 12px;

            .title {
                color: #f20c00;
                flex: 0 0 60px;
                line-height: 17px;
            }
            .content {
                color: #666666;
                flex: 1;
                line-height: 16px;
            }
            .content a{
                text-decoration:underline;
                color blue;
                font-size: 13px;
                line-height: 26px;
            }
        }
    }
}
</style>